/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       distancejoint.h
 * Author:     karooolek
 * Created on: Nov 9, 2009
 *
 **********************************************************************************************************************/

#ifndef DISTANCEJOINT_H_
#define DISTANCEJOINT_H_

#include "joint.h"

namespace mGameEngine
{
namespace Physics
{

/**
 * Distance joint.
 * Joint
 */
class DistanceJoint: public Joint
{
protected:
    /**
     * Minimal distance.
     */
    float _minDistance;

    /**
     * Maximal distance.
     */
    float _maxDistance;

    /**
     * Spring constant.
     */
    float _spring;

    /**
     * Spring damping coefficient.
     */
    float _damp;

public:
    /**
     * Create distance joint with specified minimal and maximal distance
     * and spring constant and spring damping coefficient.
     * @param minDistance minimal distance.
     * @param maxDistance maximal distance.
     * @param spring spring constant.
     * @param damp spring damping coefficient.
     */
    DistanceJoint(float minDistance = 1.0f, float maxDistance = 1.0f, float spring = 0.0f, float damp = 0.0f);

    /**
     * Destroy distance joint.
     */
    virtual ~DistanceJoint();

    /**
     * Get joint minimal distance.
     * @return joint minimal distance.
     */
    virtual float getMinimalDistance() const
    {
        return _minDistance;
    }

    /**
     * Set joint minimal distance.
     * @param minDistance minimal distance.
     */
    virtual void setMinimalDistance(float minDistance);

    /**
     * Get joint maximal distance.
     * @return joint maximal distance.
     */
    virtual float getMaximalDistance() const
    {
        return _maxDistance;
    }

    /**
     * Set joint maximal distance.
     * @param maxDistance maximal distance.
     */
    virtual void setMaximalDistance(float maxDistance);

    /**
     * Get distance joint spring constant.
     * @return distance joint spring constant.
     */
    float getSpring() const
    {
        return _spring;
    }

    /**
     * Set distance joint spring constant.
     * @param spring spring constant.
     */
    void setSpring(float spring);

    /**
     * Get distance joint spring damping coefficient.
     * @return distance joint spring damping coefficient.
     */
    float getDamping() const
    {
        return _damp;
    }

    /**
     * Set distance joint spring damping coefficient.
     * @param damp distance joint spring damping coefficient.
     */
    void setDamping(float damp);

    /**
     * Create PhysX distance joint between two PhysX actors.
     * @param actor1 first PhysX actor.
     * @param actor2 second PhysX actor.
     */
    virtual void create(NxActor *actor1, NxActor *actor2) const;
};

}

}

#endif // DISTANCEJOINT_H_
